// https://iai.sh.cn/problem/387
#include <bits/stdc++.h>
using namespace std;
int shu[100001];
long long s[100001];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> shu[i];
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + shu[i];
  }

  int ans = INT_MAX;
  for (int p = 2; p <= n; p++) {
    int sumL  = s[p-1];
    int sumR = s[n]-s[p-1];
    ans = min(ans, abs(sumR - sumL));
  }
  cout << ans;

  return 0;
}